package cn.softwin.controller.customer;

import cn.softwin.service.impl.CustumerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/deleteCustomerById")
public class DeleteCustomerServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    /**
     * Description: servlet的post请求
     * Author: zhangxiangkai
     * Params: [request, response]
     * ReturnType: void
     * Time: 2021/2/18-17:19
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        Long custId = Long.valueOf(request.getParameter("custId"));
        CustumerServiceImpl custumerService = new CustumerServiceImpl();
        boolean delUserMessage = custumerService.DeleteCustomerById(custId);
        if (delUserMessage) {
            request.getRequestDispatcher("/queryCustomerServlet").forward(request, response);
        } else {
            request.getRequestDispatcher("error.jsp").forward(request,response);
        }
    }

    
}
